package com.ft.springboottravel.service.impl;

import com.ft.springboottravel.bean.Banner;
import com.ft.springboottravel.mapper.BannerMapper;
import com.ft.springboottravel.service.BannerService;
import com.ft.springboottravel.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class BannerServiceImpl implements BannerService {
    @Autowired
    private BannerMapper bannerMapper;
    @Override
    public Pager<Banner> selectBannerAll(Integer routeId, Integer currentPage) {
            Pager<Banner> bannerPager=new Pager<>();

            bannerPager.setCurrentPage(currentPage);

            bannerPager.setPageSize(2);

            bannerPager.setList(bannerMapper.selectBannerAll(routeId, currentPage));

            bannerPager.setTotal(selectBannerTotal(routeId));

        return bannerPager;
    }

    @Override
    public Long selectBannerTotal(Integer routeId) {
        return bannerMapper.selectBannerTotal(routeId);
    }

    @Override
    public Banner selectBannerById(Integer banId) {
        return bannerMapper.selectBannerById(banId);
    }

    @Override
    public void addBanner(Banner banner) {
        bannerMapper.addBanner(banner);
    }

    @Override
    public void editBannerById(Banner banner) {
        bannerMapper.editBannerById(banner);
    }

    @Override
    public void deleteBannerById(Integer banId) {
        bannerMapper.deleteBannerById(banId);
    }
}
